package cn.codingjc.consumer.config;

import cn.codingjc.consumer.intercepter.MicroServiceHTTPIntercepter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import java.util.Collections;

/**
 * @author shenjicheng
 * @date 2022/7/3 10:36 AM
 */

@Configuration
public class RestTemplateConfig {

    @Autowired
    private MicroServiceHTTPIntercepter httpIntercepter;

    @Bean
    RestTemplate getRestTemplate() {
        RestTemplate restTemplate = new RestTemplate();
        restTemplate.setInterceptors(Collections.singletonList(httpIntercepter));
        return restTemplate;
    }
}
